load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "refresher",
    srcs = [
        "refresher.go",
        "worker.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/refresher",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/ddl/notifier",
        "//pkg/sessionctx",
        "//pkg/sessionctx/sysproctrack",
        "//pkg/sessionctx/vardef",
        "//pkg/sessionctx/variable",
        "//pkg/statistics/handle/autoanalyze/exec",
        "//pkg/statistics/handle/autoanalyze/priorityqueue",
        "//pkg/statistics/handle/logutil",
        "//pkg/statistics/handle/types",
        "//pkg/util",
        "//pkg/util/intest",
        "@com_github_pingcap_errors//:errors",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "refresher_test",
    timeout = "short",
    srcs = [
        "main_test.go",
        "refresher_test.go",
        "worker_test.go",
    ],
    flaky = True,
    shard_count = 10,
    deps = [
        ":refresher",
        "//pkg/parser/ast",
        "//pkg/sessionctx",
        "//pkg/sessionctx/sysproctrack",
        "//pkg/statistics",
        "//pkg/statistics/handle/autoanalyze/priorityqueue",
        "//pkg/statistics/handle/ddl/testutil",
        "//pkg/statistics/handle/types",
        "//pkg/statistics/handle/util",
        "//pkg/testkit",
        "//pkg/testkit/testsetup",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_goleak//:goleak",
    ],
)
